package com.heimachefu.common;


/**
 * @author liuxingdong@heimachefu.com
 * @date 2019/7/23 17:13
 */
public class CommonUtils {
    public CommonUtils() {
    }

    public static boolean isNullOrEmpty(Object obj) {
        return obj == null;
    }

    public static boolean isIntThanZero(int number) {
        return number > 0;
    }



    public static Result success(Object data) {
        Result result = new Result();
        result.setCode(Integer.valueOf(0));
        result.setMsg("操作成功！");
        result.setData(data);
        result.setError((Object)null);
        return result;
    }

    public static Result success(String msg, Object data) {
        Result result = new Result();
        result.setCode(Integer.valueOf(0));
        result.setMsg(msg);
        result.setData(data);
        result.setError((Object)null);
        return result;
    }

    public static Result error(String msg) {
        Result result = new Result();
        result.setCode(Integer.valueOf(1));
        result.setMsg(msg);
        result.setData((Object)null);
        result.setError((Object)null);
        return result;
    }

    public static Result loginFail(String msg) {
        Result result = new Result();
        result.setCode(Integer.valueOf(3));
        result.setMsg(msg);
        result.setData((Object)null);
        result.setError((Object)null);
        return result;
    }

    public static Result error(String msg, Object debug) {
        Result result = new Result();
        result.setCode(Integer.valueOf(1));
        result.setMsg(msg);
        result.setData((Object)null);
        result.setError(debug);
        return result;
    }

    public static Result error() {
        Result result = new Result();
        result.setCode(Integer.valueOf(1));
        result.setMsg("操作失败！");
        result.setData((Object)null);
        result.setError((Object)null);
        return result;
    }

    public static Result message(int count) {
        Result result = new Result();
        result.setData((Object)null);
        if (isIntThanZero(count)) {
            result.setCode(Integer.valueOf(0));
            result.setMsg("操作成功！");
            return result;
        } else {
            result.setCode(Integer.valueOf(1));
            result.setMsg("操作失败！");
            return result;
        }
    }



}
